﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace System.IO
{
    /// <summary>
    /// DirectoryInfo 扩展方法
    /// </summary>
    public static class DirectoryInfoExtension
    {
        /// <summary>
        /// 获取文件夹内所有文件
        /// </summary>
        /// <param name="d">文件夹路径</param>
        /// <param name="isSearchSubDirs">开启搜索子文件夹, 默认 true</param>
        /// <returns>返回 FileInfo 集合</returns>
        public static FileInfo[] GetFilesAdv(this DirectoryInfo d, bool isSearchSubDirs = true)
        {
            var temp = Util.IO.DirectoryUtils.GetFilesAdv(d.FullName, isSearchSubDirs);
            return temp.Select(i => new FileInfo(i)).ToArray();
        }

        /// <summary>
        /// 获取文件夹内所有文件
        /// </summary>
        /// <param name="d">文件夹路径</param>
        /// <param name="isSearchSubDirs">开启搜索子文件夹, 默认 true</param>
        /// <returns>返回 文件路径Str 集合</returns>
        public static string[] GetFilePathsAdv(this DirectoryInfo d, bool isSearchSubDirs = true)
        {
            var temp = Util.IO.DirectoryUtils.GetFilesAdv(d.FullName, isSearchSubDirs);
            return temp.ToArray();
        }
    }
}
